/*
 * spacer.c
 *
 * Asif Shahidullah
 * ECE 275, A.1
 *
 * Main file and program entry point
 */

#include <stdio.h>
#include <stdlib.h>
#include "ERR.h"
#include "read.h"


/* Entry point, overall algorith for problem should be 
 * self-explanatory by viewing only this file. */
int
main (int argc, char **argv) {
  files_t *file_handler;

  if (argc != 3) {
    fprintf (stderr, "Usage: %s <input file> <output file>\n", *argv);
    return EXIT_FAILURE;
  }

  file_handler = (files_t*) malloc (sizeof (files_t));
  if (file_handler == NULL)
    return MALLOC_FAILURE;
  if (init_files (file_handler, *(argv+1), *(argv+2)) != 0)
    return FILE_FAILURE;

  /* splice() is what actually removes whitespaces */
  splice (file_handler);

  /* some cleanup... */
  close_files (file_handler);
  free (file_handler);
  
  return EXIT_SUCCESS;
}
